<template>
	<view class="home">
		<view class="wrap">
			<u-swiper :list="list" title="true" :affect3d="true" height="350" @click="Click"></u-swiper>
		</view>

		<u-tabs-swiper ref="tabs" :list="List" :is-scroll="false" active-color="#DD6161" :current="current" @change="nav"
		 font-size="32"></u-tabs-swiper>

		<view class="" v-if="current === 0">
			<u-cell-group>
				<u-cell-item icon="grid" :title="item.intro" value="点击" :label="item.give_Address" v-for="item in BoxInfo" :key="item.id" @click="click(item.id)" v-if="item.type == 1 && item.select_paoshou == ''"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="" v-if="current === 1">
			<u-cell-group>
				<u-cell-item icon="grid" :title="item.intro" value="点击" :label="item.give_Address" v-for="item in BoxInfo" :key="item.id" @click="click(item.id)" v-if="item.type == 2 && item.select_paoshou == ''"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						image: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20180506%2Fd2a8282ab36a415d9f120ff40046939a.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1626957295&t=76b23d300b11729234e03dc39028e56d',
						title: '蒹葭苍苍，白露为霜。所谓伊人，在水一方'
					},
					{
						image: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1594034068128&di=dfcaa377823c0a28cb5e1ecc8eeb409c&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn10%2F200%2Fw600h400%2F20181110%2F9044-hnstwwq0191731.jpg',
						title: '溯洄从之，道阻且长。溯游从之，宛在水中央'
					},
					{
						image: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.mp.itc.cn%2Fupload%2F20170223%2F8cf2604b19e94762b2097290abaef9e9_th.jpeg&refer=http%3A%2F%2Fimg.mp.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1626957383&t=4c44ba8b6a1808f4d0b202f61d44e0b2',
						title: '蒹葭萋萋，白露未晞。所谓伊人，在水之湄'
					}
				],
				List: [{
					name: '代盒饭'
				}, {
					name: '代零食'
				}],
				current: 0,
				box_list:[
					{
						id:0,
						type:'汇泽食堂二楼牛肉饭',
						money:15,
						give_address:'汇泽六栋613',
						time:'2020-07-08'
					},
					{
						id:1,
						type:'汇泽食堂二楼扬州饭',
						money:15,
						give_address:'汇泽六栋703',
						time:'2020-07-12'
					},
					{
						id:2,
						type:'汇泽食堂二楼盖胞饭',
						money:15,
						give_address:'汇泽六栋603',
						time:'2020-9-25'
					}
				],
				BoxInfo:[]
			}
		},
		methods: {
			nav(index) {
				this.current = index;
			},
			Click(index) {
				console.log(index)
			},
			click(index){
				// console.log(this.BoxInfo[index-1])
				// console.log(index)
				getApp().globalData.BoxOrFood = this.BoxInfo[index-1]
				uni.navigateTo({
					url:'../../pagesC/Food_BoxDetails/Food_BoxDetails'
				})
			},
			async GetBoxMessage(){
				const res = await this.$myRequest({
					url:'GetTaskMessage'
				})
				if(res.data.code == 0){
					this.BoxInfo = res.data.message;
					console.log(this.BoxInfo)
				}
			}
		},
		onLoad() {
			this.GetBoxMessage();
			
			uni.$on('Add_Task',()=>{
				console.log('是否触发')
				this.GetBoxMessage();
			})
		}
	}
</script>

<style lang="scss" scoped>
	.home {
		width: 750rpx;

		.wrap {
			width: 100%;
			padding: 0 0 5px 0;
		}
	}
</style>
